home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_07 / guthrie / aqmsg.cpp < prev    next >
C/C++ Source or Header  |  1994-10-06  |  2KB  |  43 lines

  1. //====================== AQMSG.CPP ======================================
  2. //  AutoQueueMessage Class Implementation File.
  3. //  R. Scott Guthrie - Original Code Creation
  4. //=======================================================================
  5. #include "AQMSG.HPP"
  6. #include <iomanip.h>
  7.  
  8. // ----- FindByNumber -----
  9. AutoQueueMessage* AutoQueueMessage::FindByNumber(const int Number)
  10. { if(IsLinked())                        // If this is a queued instance...
  11.   { AutoQueueMessage* Tmp = (AutoQueueMessage*)GetFirstNode();
  12.     while(Tmp)                          // While there are nodes...
  13.     { if(Tmp->Number_ == Number)        // If this is a match
  14.         return Tmp;                     // return its address,
  15.       Tmp = (AutoQueueMessage*)Tmp->GetNextNode(); // else, get next instance.
  16.     }
  17.   }
  18.   else                                  // This is not a queued instance.
  19.   { if(Number_ == Number)               // If this matches
  20.       return this;                      // return its address,
  21.   }
  22.   return 0;                             // otherwise return 0.
  23. }
  24.  
  25. // ----- List -----
  26. // This method displays the contents of the list for which the current
  27. // instance is a member.
  28. void AutoQueueMessage::List()
  29. { if(IsLinked())                        // If this is a linked instance...
  30.   { AutoQueueMessage* Tmp = (AutoQueueMessage*)GetFirstNode();
  31.     while(Tmp)                          // As long as there are nodes...
  32.     {                                   // display instance data.
  33.       cout << setw(4) << Tmp->Number_ << "  \"" << Tmp->Text_ << "\"" << endl;
  34.       Tmp = (AutoQueueMessage*)Tmp->GetNextNode();  // Next Instance...
  35.     }
  36.   }
  37.   else
  38.   { // Output a single line for the stand alone instance.
  39.     cout << setw(4) << Number_ << "  \"" << Text_ << "\"" << endl;
  40.   }
  41. }
  42. // end file AQMSG.CPP
  43.